using UnityEngine;
using UnityEngine.UI;
using QFramework;
using System;

namespace QFramework.Adventure
{
	public class GameDetailPanelData : UIPanelData
	{
	}
	public partial class GameDetailPanel : UIPanel
	{
		protected override void OnInit(IUIData uiData = null)
		{
			mData = uiData as GameDetailPanelData ?? new GameDetailPanelData();
			// please add init code here
		}
		
		protected override void OnOpen(IUIData uiData = null)
		{

			UIEventTrigger.Get(btn_use).onClick = UseFun;
			UIEventTrigger.Get(btn_figure).onClick = FigureFun;
			UIEventTrigger.Get(btn_close).onClick = CloseFun;
			InitUseFun();

        }

	

		protected override void OnShow()
		{
		}
		
		protected override void OnHide()
		{
		}
		
		protected override void OnClose()
		{
            UIEventTrigger.Get(btn_use).onClick = null;
            UIEventTrigger.Get(btn_figure).onClick = null;
            UIEventTrigger.Get(btn_close).onClick = null;
        }
        //===============>
        private void CloseFun(GameObject go)
        {
            AudioKit.PlaySound(GameConfig.Auido_Btn01);
			CloseSelf();
        }

        private void FigureFun(GameObject go)
        {
            AudioKit.PlaySound(GameConfig.Auido_Btn01);
			obj_use.gameObject.SetActive(false);
			obj_figure.gameObject.SetActive(true);

            btn_use.GetComponent<Text>().color = new Color(1, 1, 1);
            btn_figure.GetComponent<Text>().color = new Color(1, 0, 0);
        }

        private void UseFun(GameObject go)
        {
            AudioKit.PlaySound(GameConfig.Auido_Btn01);


			InitUseFun();
        }

		void InitUseFun()
        {
            obj_use.gameObject.SetActive(true);
            obj_figure.gameObject.SetActive(false);

            btn_use.GetComponent<Text>().color = new Color(1, 0, 0);
            btn_figure.GetComponent<Text>().color = new Color(1, 1, 1);
        }
    }
}
